import java.util.*;

class Solution {

    public Solution() {
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();

        // 使用HashMap来统计每个关键词的搜索频次
        Map<String, Integer> keywordFrequencyMap = new HashMap<>();

        // 使用正则表达式将输入字符串分割成关键词数组
        String[] keywords = input.split(" ");

        // 统计每个关键词的搜索频次
        for (String keyword : keywords) {
            keywordFrequencyMap.put(keyword, keywordFrequencyMap.getOrDefault(keyword, 0) + 1);
        }

        // 创建一个关键词比较器，用于按频次从高到低和字典序升序排序关键词
        Comparator<String> keywordComparator = (k1, k2) -> {
            int freq1 = keywordFrequencyMap.get(k1);
            int freq2 = keywordFrequencyMap.get(k2);
            if (freq1 != freq2) {
                return freq2 - freq1; // 频次从高到低排序
            } else {
                return k1.compareTo(k2); // 频次相同按字典序升序排序
            }
        };

        // 使用TreeSet来进行排序
        TreeSet<String> sortedKeywords = new TreeSet<>(keywordComparator);
        sortedKeywords.addAll(keywordFrequencyMap.keySet());

        // 输出排序后的关键词
        for (String keyword : sortedKeywords) {
            System.out.println(keyword);
        }
    }


    public int maximumRows(List<List<Integer>> mat, int cols) {
        int n = mat.size();
        int m = mat.get(0).size();
        int maxx = 1 << m;

        int ans = 0;
        for (int x = 0; x <= maxx; x++) {
            int cnt = Integer.bitCount(x);
            if (cols == cnt) {
                cnt = 0;
                for (int i = 0; i < n; i++) {
                    boolean flag = true;
                    for (int j = 0; j < m && flag; j++) {
                        if (mat.get(i).get(j) == 1 && ((x >> j) % 2 == 0)) {
                            flag = false;
                        }
                    }
                    cnt += flag ? 1 : 0;
                }
                ans = Math.max(ans, cnt);
            }
        }

        return ans;
    }
}